package com.itbbfx.controller.statistics;

import com.itbbfx.service.department.FinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 统计管理
 */
@RestController
@RequestMapping("/statistics")
public class StatisticsController {
    @Autowired
    private FinanceService cashierService;

    @RequestMapping("/reportYearFinance")
    public Object reportYearFinance(String year) {
        List<Double> months = cashierService.reportYearFinance(year);
        for (int i = 0; i < months.size(); i++) {
            if(null == months.get(i)){
                months.set(i,0.0);
            }
        }

        return months;
    }

    @RequestMapping("/reportYearBingFinance")
    public Object reportYearBingFinance() {
        return cashierService.reportYearBingFinance();
    }

    @RequestMapping("/inpatientFinance")
    public Object inpatientFinance(String year) {
        List<Double> months = cashierService.inpatientFinance(year);
        for (int i = 0; i < months.size(); i++) {
            if(null == months.get(i)){
                months.set(i,0.0);
            }
        }

        return months;
    }

    @RequestMapping("/inpatientYearBingFinance")
    public Object inpatientYearBingFinance() {
        return cashierService.inpatientYearBingFinance();
    }
}